<html><head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta content="text/javascript" http-equiv="content-script-type">
<title>tango.util.container.HashSet</title>

<link rel="stylesheet" type="text/css" href="css/style.css">
<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="css/ie56hack.css"><![endif]-->
<script language="JavaScript" src="js/util.js" type="text/javascript"></script>
<script language="JavaScript" src="js/tree.js" type="text/javascript"></script>
<script language="JavaScript" src="js/explorer.js" type="text/javascript"></script>
<script>
function anchorFromTitle(title, path, ext) {
  var url = path + title + "." + ext;
  document.write("<a href='" + url + "'>" + title + "</a>");
  }
</script>
</head><body>
<div id="tabarea"></div><div id="explorerclient"></div>
<div id="content"><script>explorer.initialize("tango.util.container.HashSet");</script>
        <table class="content">
                <tr><td id="docbody"><h1><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791">tango.util.container.HashSet</a></h1>
                
<b>License:</b><br>
BSD style: see <a href="http://www.dsource.org/projects/tango/wiki/LibraryLicense">license.txt</a><br><br>
<b>Version:</b><br>
Apr 2008: Initial release<br><br>
<b>Authors:</b><br>
Kris<br><br>
<b>Since:</b><br>0.99.7<br><br>        Based upon Doug Lea's Java collection package<br><br>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>class <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L55">HashSet</a></span>
<script>explorer.outline.addDecl('HashSet');</script>(V, alias Hash = Container.hash, 
                  alias Reap = Container.reap, 
                  alias Heap = Container.Collect) : IContainer!(V);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Hash table implementation of a Set</font><br><br>
<font color="black"><pre class="d_code">

        <span class="i">Iterator</span> <span class="i">iterator</span> ()
        <span class="k">int</span> <span class="i">opApply</span> (<span class="k">int</span> <span class="k">delegate</span>(<span class="k">ref</span> <span class="i">V</span> <span class="i">value</span>) <span class="i">dg</span>)

        <span class="k">bool</span> <span class="i">add</span> (<span class="i">V</span> <span class="i">element</span>)
        <span class="k">bool</span> <span class="i">contains</span> (<span class="i">V</span> <span class="i">element</span>)
        <span class="k">bool</span> <span class="i">take</span> (<span class="k">ref</span> <span class="i">V</span> <span class="i">element</span>)
        <span class="k">bool</span> <span class="i">remove</span> (<span class="i">V</span> <span class="i">element</span>)
        <span class="k">uint</span> <span class="i">remove</span> (<span class="i">IContainer</span>!(<span class="i">V</span>) <span class="i">e</span>)
        <span class="k">bool</span> <span class="i">replace</span> (<span class="i">V</span> <span class="i">oldElement</span>, <span class="i">V</span> <span class="i">newElement</span>)

        <span class="k">uint</span> <span class="i">size</span> ()
        <span class="k">bool</span> <span class="i">isEmpty</span> ()
        <span class="i">V</span>[] <span class="i">toArray</span> (<span class="i">V</span>[] <span class="i">dst</span>)
        <span class="i">HashSet</span> <span class="i">dup</span> ()
        <span class="i">HashSet</span> <span class="i">clear</span> ()
        <span class="i">HashSet</span> <span class="i">reset</span> ()

        <span class="k">uint</span> <span class="i">buckets</span> ()
        <span class="k">void</span> <span class="i">buckets</span> (<span class="k">uint</span> <span class="i">cap</span>)
        <span class="k">float</span> <span class="i">threshold</span> ()
        <span class="k">void</span> <span class="i">threshold</span> (<span class="k">float</span> <span class="i">desired</span>)
        
</pre><br><br></font><br><br>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li><span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L88">this</a></span>
<script>explorer.outline.addDecl('this');</script>(float <span class="funcparam">f</span> = Container.defaultLoadFactor);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Construct a HashSet instance</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>~<span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L99">this</a></span>
<script>explorer.outline.addDecl('this');</script>();</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Clean up when deleted</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Alloc <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L110">allocator</a></span>
<script>explorer.outline.addDecl('allocator');</script>(); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Return the configured allocator
                
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Iterator <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L121">iterator</a></span>
<script>explorer.outline.addDecl('iterator');</script>(); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Return a generic iterator for contained elements
                
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>int <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L137">opApply</a></span>
<script>explorer.outline.addDecl('opApply');</script>(int delegate(ref V value) <span class="funcparam">dg</span>); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>uint <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L149">size</a></span>
<script>explorer.outline.addDecl('size');</script>(); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Return the number of elements contained
                
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>bool <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L164">add</a></span>
<script>explorer.outline.addDecl('add');</script>(V <span class="funcparam">element</span>); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Add a new element to the set. Does not add if there is an
                equivalent already present. Returns true where an element
                is added, false where it already exists
                
                Time complexity: O&#40;1&#41; average; O&#40;n&#41; worst.
                
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>bool <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L192">contains</a></span>
<script>explorer.outline.addDecl('contains');</script>(V <span class="funcparam">element</span>); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Does this set contain the given element?
        
                Time complexity: O&#40;1&#41; average; O&#40;n&#41; worst
                
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>HashSet <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L212">dup</a></span>
<script>explorer.outline.addDecl('dup');</script>(); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Make an independent copy of the container. Does not clone
                elements
                
                Time complexity: O&#40;n&#41;
                
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>uint <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L235">remove</a></span>
<script>explorer.outline.addDecl('remove');</script>(V <span class="funcparam">element</span>, bool <span class="funcparam">all</span>); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Remove the provided element. Returns true if found, false
                otherwise
                
                Time complexity: O&#40;1&#41; average; O&#40;n&#41; worst</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>bool <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L249">remove</a></span>
<script>explorer.outline.addDecl('remove');</script>(V <span class="funcparam">element</span>); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Remove the provided element. Returns true if found, false
                otherwise
                
                Time complexity: O&#40;1&#41; average; O&#40;n&#41; worst</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>uint <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L291">replace</a></span>
<script>explorer.outline.addDecl('replace');</script>(V <span class="funcparam">oldElement</span>, V <span class="funcparam">newElement</span>, bool <span class="funcparam">all</span>); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Replace the first instance of oldElement with newElement.
                Returns true if oldElement was found and replaced, false
                otherwise.
                
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>bool <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L304">replace</a></span>
<script>explorer.outline.addDecl('replace');</script>(V <span class="funcparam">oldElement</span>, V <span class="funcparam">newElement</span>); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Replace the first instance of oldElement with newElement.
                Returns true if oldElement was found and replaced, false
                otherwise.
                
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>bool <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L326">take</a></span>
<script>explorer.outline.addDecl('take');</script>(ref V <span class="funcparam">element</span>); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Remove and expose the first element. Returns false when no
                more elements are contained
        
                Time complexity: O&#40;n&#41;</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L345">add</a></span>
<script>explorer.outline.addDecl('add');</script>(IContainer!(V) <span class="funcparam">e</span>); [public]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>uint <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L355">remove</a></span>
<script>explorer.outline.addDecl('remove');</script>(IContainer!(V) <span class="funcparam">e</span>); [public]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>HashSet <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L374">clear</a></span>
<script>explorer.outline.addDecl('clear');</script>(); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Clears the HashMap contents. Various attributes are
                retained, such as the internal table itself. Invoke
                reset&#40;&#41; to drop everything.</font><br><br>
<font color="black">Time complexity: O&#40;n&#41;
                
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>HashSet <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L388">reset</a></span>
<script>explorer.outline.addDecl('reset');</script>(); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Reset the HashSet contents and optionally configure a new
                heap manager. This releases more memory than clear&#40;&#41; does</font><br><br>
<font color="black">Time complexity: O&#40;1&#41;
                
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>uint <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L404">buckets</a></span>
<script>explorer.outline.addDecl('buckets');</script>(); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Return the number of buckets</font><br><br>
<font color="black">Time complexity: O&#40;1&#41;<br><br></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L417">buckets</a></span>
<script>explorer.outline.addDecl('buckets');</script>(uint <span class="funcparam">cap</span>); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Set the number of buckets and resize as required
                
                Time complexity: O&#40;n&#41;</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>float <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L434">threshold</a></span>
<script>explorer.outline.addDecl('threshold');</script>(); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Return the resize threshold
                
                Time complexity: O&#40;1&#41;</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L447">threshold</a></span>
<script>explorer.outline.addDecl('threshold');</script>(float <span class="funcparam">desired</span>); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Set the resize threshold, and resize as required
                
                Time complexity: O&#40;n&#41;
                
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>V[] <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L467">toArray</a></span>
<script>explorer.outline.addDecl('toArray');</script>(V[] <span class="funcparam">dst</span> = null); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Copy and return the contained set of values in an array, 
                using the optional dst as a recipient &#40;which is resized 
                as necessary&#41;.</font><br><br>
<font color="black">Returns a slice of dst representing the container values.
                
                Time complexity: O&#40;n&#41;
                
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>bool <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L486">isEmpty</a></span>
<script>explorer.outline.addDecl('isEmpty');</script>(); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Is this container empty?
                
                Time complexity: O&#40;1&#41;
                
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>HashSet <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L497">check</a></span>
<script>explorer.outline.addDecl('check');</script>(); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Sanity check
                 
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Ref <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L526">allocate</a></span>
<script>explorer.outline.addDecl('allocate');</script>(); [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Allocate a node instance. This is used as the default allocator
                 
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L538">checkLoad</a></span>
<script>explorer.outline.addDecl('checkLoad');</script>(); [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Check to see if we are past load factor threshold. If so,
                 resize so that we are at half of the desired threshold.
                 
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L552">resize</a></span>
<script>explorer.outline.addDecl('resize');</script>(uint <span class="funcparam">newCap</span>); [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">resize table to new capacity, rehashing all elements
                
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>bool <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L583">remove</a></span>
<script>explorer.outline.addDecl('remove');</script>(Ref <span class="funcparam">node</span>, uint <span class="funcparam">row</span>); [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Remove the indicated node. We need to traverse buckets
                for this, since we're singly-linked only. Better to save
                the per-node memory than to gain a little on each remove</font><br><br>
<font color="black">Used by iterators only
                 
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>HashSet <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L620">clear</a></span>
<script>explorer.outline.addDecl('clear');</script>(bool <span class="funcparam">all</span>); [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Clears the HashSet contents. Various attributes are
                retained, such as the internal table itself. Invoke
                reset&#40;&#41; to drop everything.</font><br><br>
<font color="black">Time complexity: O&#40;n&#41;
                
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L648">increment</a></span>
<script>explorer.outline.addDecl('increment');</script>(); [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">new element was added
                
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L660">decrement</a></span>
<script>explorer.outline.addDecl('decrement');</script>(Ref <span class="funcparam">p</span>); [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">element was removed
                
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L674">mutate</a></span>
<script>explorer.outline.addDecl('mutate');</script>(); [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">set was changed
                
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>struct <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L685">Freach</a></span>
<script>explorer.outline.addDecl('Freach');</script>; [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">foreach support for iterators
                
</font><br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>struct <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/HashSet.d?rev=3791#L707">Iterator</a></span>
<script>explorer.outline.addDecl('Iterator');</script>; [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Iterator with no filtering</font><br><br>
</dd></dl></dd></dl></td></tr>
                <tr><td id="docfooter">
                        Copyright (c) 2008 Kris Bell. All rights reserved :: page rendered by CandyDoc. Generated by <a href="http://code.google.com/p/dil">dil</a> on Sat Aug  2 16:08:33 2008.
                </td></tr>
        </table>
</div>
<script></script>
</body></html>